package org.stone.project.logInterface.utils;

import org.stone.project.common.pojo.constant.SysConstant;

/**
 * 日志字符处理工具
 */
public class LogStrUtil {
    private static String slitRegStr = "\\{\\}";
    private static String slitStr = "{}";

    //获取日志字符串
    public static String getLogStr(String msg, Object... args){
        if (args.length == 0){
            msg.replace(slitStr, SysConstant.EMPTY_STR);
            return msg;
        }
        else {
            StringBuffer logStr = new StringBuffer();
            String[] strSub = msg.split(slitRegStr);
            Integer maxIndex = args.length-1;
            for (int i = 0; i < strSub.length; i++) {
                logStr.append(strSub[i]);
                if (i<=maxIndex)
                    logStr.append(args[i]);
            }
            return logStr.toString();
        }
    }
}
